home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / m68k / stackswap.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  1.3 KB  |  76 lines

  1. |*****************************************************************************
  2. |
  3. |   NAME
  4. |
  5. |    __AROS_LH1(void, StackSwap,
  6. |
  7. |   SYNOPSIS
  8. |    __AROS_LA(struct StackSwapStruct *, newStack, A0),
  9. |
  10. |   LOCATION
  11. |    struct ExecBase *, SysBase, 122, Exec)
  12. |
  13. |   FUNCTION
  14. |    This function switches to the new stack given by the parameters in the
  15. |    stackswapstruct structure. The old stack parameters are returned in
  16. |    the same structure so that the stack can be restored later
  17. |
  18. |   INPUTS
  19. |    newStack - parameters for the new stack
  20. |
  21. |   RESULT
  22. |
  23. |   NOTES
  24. |
  25. |   EXAMPLE
  26. |
  27. |   BUGS
  28. |
  29. |   SEE ALSO
  30. |
  31. |   INTERNALS
  32. |
  33. |   HISTORY
  34. |
  35. |******************************************************************************
  36.  
  37.     Disable     =    -0x78
  38.     Enable        =    -0x7e
  39.     ThisTask    =    0x114
  40.     tc_SPLower  =    0x3a
  41.  
  42.     .globl    _Exec_StackSwap
  43. _Exec_StackSwap:
  44.     | Preserve returnaddress and fix sp
  45.     movel    sp@+,d0
  46.  
  47.     | Get pointer to tc_SPLower in a1 (tc_SPUpper is next)
  48.     movel    a6@(ThisTask),a1
  49.     leal    a1@(tc_SPLower),a1
  50.  
  51.     | Just to be sure interrupts always find a good stackframe
  52.     jsr    a6@(Disable)
  53.  
  54.     | Swap Lower boundaries
  55.     movel    a1@,d1
  56.     movel    a0@,a1@+
  57.     movel    d1,a0@+
  58.  
  59.     | Swap higher boundaries
  60.     movel    a1@,d1
  61.     movel    a0@,a1@
  62.     movel    d1,a0@+
  63.  
  64.     | Swap stackpointers
  65.     movel    sp,d1
  66.     movel    a0@,sp
  67.     movel    d1,a0@
  68.  
  69.     | Reenable interrupts.
  70.     jsr    a6@(Enable)
  71.  
  72.     | Restore returnaddress and return
  73.     movel    d1,sp@-
  74.     rts
  75.  
  76.